/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package holdem.network;

import java.io.Serializable;
import java.lang.reflect.Field;



/**
 *
 * @author Anders
 */
public abstract class NetworkRequest implements Serializable
{
    protected int playerID = -1;

    public void setPlayerID(int playerID)
    {
        this.playerID = playerID;
    }

    public int getPlayerID()
    {
        return playerID;
    }

    @Override
    public String toString() {
        String className = this.getClass().getSimpleName();
        String all = "[" + className;
        for(Field f : this.getClass().getDeclaredFields()) {
            f.setAccessible(true);
            String fieldName = f.getName();
            try {
                fieldName += " " + f.get(this).toString();
            } catch (Exception ex) {
            }
            all += "|" + fieldName;
        }
        all += "]";
        return all;
    }

    public abstract void event(MessageReceiverInCommunicationModule msg);
}

class BetRequest extends NetworkRequest
{

    private int amount;
    
    public BetRequest(int amount) 
    {
        this.amount = amount;
    }

    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.bet(amount, playerID);
    }
}
class RaiseRequest extends NetworkRequest
{
    private int amount;

    public RaiseRequest(int amount)
    {
        this.amount = amount;
    }

    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.raise(amount, playerID);
    }

}
class FoldRequest extends NetworkRequest
{
    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.fold(playerID);
    }

}
class CheckRequest extends NetworkRequest
{
    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.check(playerID);
    }
}
class QuitRequest extends NetworkRequest
{

    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.quit(playerID);
    }

}

class StartRequest extends NetworkRequest
{
    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.start();
    }
}

class letMeJoinRequest extends NetworkRequest
{
    private String strName;
    private int money;

    public letMeJoinRequest(String strName, int money)
    {
        this.strName = strName;
        this.money = money;
    }

    @Override
    public void event(MessageReceiverInCommunicationModule msg)
    {
        msg.letMeJoin(strName, money, playerID);
    }
}